<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<!--sidebar-menu-->
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<!--sidebar-menu-->
<div id="content">
  <div id="content-header">
    <div id="breadcrumb"> <a href="<?=BASEURL?>luckydog" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 主页</a> <a  href="javascript:void(0);" class="current tip-bottom">管理员信息</a> </div>
  </div>
  <div class="container-fluid">
    <div class="row-fluid">
      <div class="span12">
        <div class="widget-box">
          <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <h5>管理员信息</h5>
          </div>
          <div class="widget-content nopadding" >
            <table class="table table-bordered" >
              <tbody>
                <tr>
                    <td>用户名</td>
                    <td><input id="username" type="text" value="<?=$manager_info['username']?>" onkeyup="J_keyup('username');" placeholder="请输入用户名"/></td>
                </tr>
                <tr>
                    <td>邮箱</td>
                    <td><input id="email" type="text" value="<?=$manager_info['email']?>" onkeyup="J_keyup('email');" placeholder="请输入邮箱"/></td>
                </tr>
                <tr>
                    <td>新密码</td>
                    <td><input id="J_newpassword" type="password" placeholder="●●●●●●" onkeyup="J_keyup('J_newpassword');"/></td>
                </tr>
                <tr>
                    <td>再次输入新密码</td>
                    <td><input id="J_verify_psw" type="password" placeholder="●●●●●●" onkeyup="J_keyup('J_verify_psw');"/></td>
                </tr>
                
                <tr>
                    <td style="border-right: 0;">&nbsp;</td>
                    <td style="border-left: 0;"><a style="float:left" class="js_btn" href="javascript:void(0);" id="edit_manager">保存</a></td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!--Footer-part-->
<!--end-Footer-part-->
</body>
</html>
<script src="<?= STATICURL; ?>js/jquery.min.js"></script>
<script>
   $(document).ready(function(){	 
    $("#edit_manager").click(function(){
        var username = $("#username").val();
        var email = $("#email").val();
        var password = $("#J_newpassword").val();
        var verify_psw = $("#J_verify_psw").val();
        var sname = $("#sname").val();
        if(username == '')
        {
            alert("用户名不能为空");                     
            return false;
        }
        if(sname == '')
        {       
            alert("单位名不能为空");  
            return false;
        }
        if(email== '')
        {
            alert("邮箱不能为空");                     
            return false;
        }
        if(password != "" || verify_psw != "")
        {
            if(password != verify_psw)
            {
                alert("两次密码不一致");
                return false;
            }
        }
         $.post("/luckydog/manager/edit_manager",{"username":username,"password":password,'sname':sname,'email':email},function(res){
            if (res.code == 1) {
                  alert('保存成功');
                  window.location.reload();
              } else if(res.code < 0)
              {
                alert(res.message);
                window.location.href="<?=BASEURL?>luckydog/manager"
              }         
        },"json");
   });
});
function J_keyup(data) {
    var _this = $("#"+data);
	var _val = _this.val();
	var tmp = _this.val();

	tmp = tmp.replace(/ /g, "");
	tmp = tmp.replace(/。/g, ".");

	if (tmp != _val) {
		_this.val(tmp);
	}
};
</script>

